#include<bits/stdc++.h>
using namespace std;
int n,m,l,v,p[100010],k;
int sum[3010];
struct as
{
    int d,v,a,dm;
}s[100010];
void solve1()
{
    int ma=0,ans=0;
    for(int i=1;i<=m;i++)
        ma=max(ma,p[i]);
    for(int i=1;i<=n;i++)
    {
        if(s[i].d<=ma&&s[i].v>v)
            ans++;
    }
    cout<<ans<<" ";
    if(ans==0)
        cout<<m;
    else cout<<m-1;
    cout<<endl;
}
void solve2()
{
    int ma=0,ans=0,o;
    for(int i=1;i<=m;i++)
        ma=max(ma,p[i]);
    for(int i=1;i<=n;i++)
    {
        o=s[i].v*s[i].v+2*s[i].a*(ma-s[i].d);
        if(s[i].d<=ma&&o>v*v)
            ans++;
    }
    cout<<ans<<" ";
    if(ans==0) cout<<m;
    else cout<<m-1;
    cout<<endl;
}
void solve4()
{
    int ans=0,f;
    memset(sum,0,sizeof sum);
    for(int i=1;i<=n;i++)
    {
        f=0;
        for(int j=1;j<=m;j++)
        {
            if(p[j]<s[i].d) continue;
            if(s[i].v*s[i].v+2*s[i].a*(p[j]-s[i].d)>v*v)
                sum[i]=sum[i]|(1<<(j-1)),f=1;
        }
        ans+=f;
    }
    cout<<ans<<" ";
    queue<int>q;
    for(int i=0;i<=(1<<(m+1));i++)
    {
        f=0;
        for(int j=1;j<=n;j=j+1)
        {
            if(sum[j]==0) continue;
            if((sum[j]&i)==0)
            {
                f=1;
                break;
            }
        }
        if(f==0) q.push(i);
    }
    ans=100000;
    int w=0;
    while(!q.empty())
    {
        f=q.front();
        q.pop();
        w=0;
        while(f>0)
        {
            w+=f%2;
            f/=2;
        }
        ans=min(ans,w);
    }
    ans=min(ans,w);
    cout<<m-ans<<endl;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int t,f1,f2,f3;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        cin>>n>>m>>l>>v;
        f1=0,f2=0,f3=0;
        for(int j=1;j<=n;j++)
        {
            cin>>s[j].d>>s[j].v>>s[j].a;
            if(s[j].a>0)
                f1=1,f3=1;
            else if(s[j].a<0)
                f1=1,f2=1;
        }
        for(int j=1;j<=m;j++)
            cin>>p[j];
        if(f1==0)
            solve1();
        else if(f2==0)
            solve2();
        else if(f3==0)
            solve4();
        else solve4();
    }
    return 0;
}
